import {BasicColumn, FormSchema} from '/@/components/Table';
import {rules} from '/@/utils/helper/validator';
import {render} from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
  {
    title: '手机号',
    dataIndex: 'username',
    width: 120,
  },
  {
    title: '姓名',
    dataIndex: 'realname',
    width: 100,
  },
  // {
  //   title: '昵称',
  //   dataIndex: 'nickname',
  //   width: 100,
  // },
  // {
  //   title: '头像',
  //   dataIndex: 'avatar',
  //   width: 120,
  //   customRender: render.renderAvatar,
  // },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    filters: [
      { text: '正常', value: '1' },
      { text: '冻结', value: '0' },
    ],
    filterMultiple: false,
    slots: { customRender: 'statusSlot' },
  },
  {
    title: '创建时间',
    sorter: true,
    dataIndex: 'createTime',
    width: 100,
  },
];

export const recycleColumns: BasicColumn[] = [
  {
    title: '手机号',
    dataIndex: 'username',
    width: 100,
  },
  {
    title: '姓名',
    dataIndex: 'realname',
    width: 100,
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    filters: [
      { text: '正常', value: '1' },
      { text: '冻结', value: '0' },
    ],
    filterMultiple: false,
    slots: { customRender: 'statusSlot' },
  },
  {
    title: '创建时间',
    sorter: true,
    dataIndex: 'createTime',
    width: 100,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '手机号',
    field: 'username',
    component: 'JInput',
    colProps: {span: 5},
  },
  {
    label: '姓名',
    field: 'realname',
    component: 'JInput',
    colProps: {span: 5},
  },
  {
    label: "创建时间",
    field: "createTime",
    component: 'RangePicker',
    componentProps: {
      showTime: true,
    },
    colProps: {span: 10},
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '手机号',
    field: 'username',
    component: 'Input',
    dynamicRules: ({model, schema}) => {
      return [
        {required: true,message: '请输入手机号',},
        { ...rules.duplicateCheckRule('sys_user', 'username', model, schema, true)[0] },
        {pattern: /^1[3|4|5|7|8|9][0-9]\d{8}$/, message: '手机号码格式有误'},
      ];
    },
  },
  {
    label: '姓名',
    field: 'realname',
    required: true,
    component: 'Input',
  },
  // {
  //   label: '昵称',
  //   field: 'nickname',
  //   required: true,
  //   component: 'Input',
  // },
  {
    label: '登录密码',
    field: 'password',
    component: 'StrengthMeter',
    rules: [
      {
        required: true,
        message: '请输入登录密码',
      },
    ],
  },
  {
    label: '确认密码',
    field: 'confirmPassword',
    component: 'InputPassword',
    dynamicRules: ({values}) => rules.confirmPassword(values, true),
  },
  // {
  //   label: '头像',
  //   field: 'avatar',
  //   component: 'JImageUpload',
  //   componentProps: {
  //     fileMax: 1,
  //     bizPath: 'user/pic',
  //   },
  // },
  {
    label: '公司绑定',
    field: 'businessIds',
    component: 'JSelectMultiple',
    required: true,
    componentProps:{
      dictCode: "caishui_business,name,id,type=1"
    },
  },
];

